package com.example.easy.Service.Impl;

import com.example.easy.Dto.Notice;
import com.example.easy.Dto.ResourceProtection;
import com.example.easy.Service.myservice.NoticeServise;
import com.example.easy.Service.myservice.ResourceProtectionServise;
import com.example.easy.mapper.NoticeMapper;
import com.example.easy.mapper.ResourceProtectionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ResourceProtectionServiselmpl implements ResourceProtectionServise {

    @Autowired
    ResourceProtectionMapper resourceProtectionMapper;


    @Override
    public int insResourceProtection(ResourceProtection resourceProtection) {
        return resourceProtectionMapper.insResourceProtection(resourceProtection);
    }

    @Override
    public int updateResourceProtection(ResourceProtection resourceProtection) {
        if (resourceProtectionMapper.selectResourceProtection(resourceProtection.getNumber())!=null) {
            resourceProtectionMapper.updateResourceProtection(resourceProtection);
            return 1;
        }else
        return 0;
    }

    @Override
    public int deleteResourceProtection(int number) {
        if (resourceProtectionMapper.selectResourceProtection(number)!=null) {
            resourceProtectionMapper.deleteResourceProtection(number);
            return 1;
        }else return 0;
    }

    @Override
    public ResourceProtection selectResourceProtection(int number) {

        if (resourceProtectionMapper.selectResourceProtection(number)!=null) {
            return resourceProtectionMapper.selectResourceProtection(number);
        }else
        return null;
    }

    @Override
    public List<ResourceProtection> selectall() {
        return resourceProtectionMapper.selectall();
    }
}
